package com.ccx.library.handler.Aspect;

import com.ccx.library.function.annotation.Permmission;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class PermmissionHandler {

    @Pointcut("@annotation(com.ccx.library.function.annotation.Permmission)")
    public void Permmission(){}

    @Before("@annotation(Permmission)")
    public void doPermmission(JoinPoint joinPoint, Permmission Permmission){
        String value = Permmission.value();
        String roleValue = value.substring(0, value.indexOf(":"));
        String moduleValue = value.substring(value.indexOf(":")+1, value.lastIndexOf(":"));
        String permValue = value.substring(value.lastIndexOf(":")+1, value.length());
        log.info(roleValue);
        log.info(moduleValue);
        log.info(permValue);
    }
}
